package main

import "github.com/go-gomail/gomail"

//代码重用
//代码简化
//接口对接
//interface设置可拓展

func SendResult(email string, word string, filepathlist []string) bool {
	m := gomail.NewMessage()
	m.SetHeader("From", "yinc13@mails.tsinghua.edu.cn")
	m.SetHeader("To", email, "yinc13@mails.tsinghua.edu.cn")
	m.SetAddressHeader("Cc", "yinc13@mails.tsinghua.edu.cn", "专业营销数据服务")
	m.SetHeader("Subject", "尊敬的客户你要的数据到了-关于"+word)
	m.SetBody("text/html", "尊敬的用户您好，营销数据请查收")
	for i := 0; i < len(filepathlist); i++ {
		m.Attach(filepathlist[i]) //追加附件
	}
	d := gomail.NewDialer("smtp.tsinghua.edu.cn", 25,
		"yinc13@mails.tsinghua.edu.cn", "tsinghua8848OK")
	if err := d.DialAndSend(m); err != nil {
		return false
	} else {
		return true
	}

}

func main() {

	SendResult("498725951@qq.com", "你没", []string{"C:\\Users\\Tsinghua-yincheng\\Desktop\\day15\\中间件.doc", "C:\\Users\\Tsinghua-yincheng\\Desktop\\day15\\微服务特色.png"})

}
